﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template2.Master" AutoEventWireup="true" CodeBehind="DetailsProduct.aspx.cs" Inherits="EnglishAuction.DetailsProduct" %>

<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="aj" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script>
        $(function () {
            $("#tabs").tabs();
            $("#ContentPlaceHolder1_txtGiaDau").autoNumeric({ aSep: ',' });
        });

    </script>
    <form id="form1" runat="server">
        <script type="text/javascript">
            var thoiGian = '<%=JsonDate%>';
            function cdtd() {
                var timer;
                var xmas = new Date(thoiGian);
                var now = new Date();
                var timeDiff = xmas.getTime() - now.getTime();
                if (timeDiff <= 0) {
                    document.getElementById("txtCountdown").innerHTML = "Sản phẩm hết hạn đấu giá.";
                    document.getElementById("ContentPlaceHolder1_fvSanPhamDauGia_btnStartAuction").value = "Sản phẩm hết hạn đấu giá";
                    document.getElementById("ContentPlaceHolder1_fvSanPhamDauGia_btnStartAuction").disabled = true;
                    document.getElementById("ContentPlaceHolder1_panelDauGia").style.display = "none";
                    clearTimeout();
                }
                else {
                    var seconds = Math.floor(timeDiff / 1000);
                    var minutes = Math.floor(seconds / 60);
                    var hours = Math.floor(minutes / 60);
                    var days = Math.floor(hours / 24);
                    hours %= 24;
                    minutes %= 60;
                    seconds %= 60;

                    var s = "";
                    if (days != 0) {
                        s += "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + days + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> ngày </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + hours + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giờ </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + minutes + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giây </span>";
                    }
                    else if (hours != 0) {
                        s = "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + hours + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giờ </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + minutes + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giây </span>";
                    }
                    else if (minutes != 0) {
                        s = "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + minutes + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giây </span>";
                    }
                    else {
                        s = "<span style='color:#E28D00;font-weight:bold;font-size:18px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:13px; padding-top:-5px;'> giây </span>";
                    }

                    document.getElementById("txtCountdown").innerHTML = s;
                    timer = setTimeout('cdtd()', 1000);
                }
            }
        </script>
        <link href="StyleSheet.css" rel="stylesheet" />
        <div style="padding-top: 5px;">
            <asp:ScriptManager ID="scriptManager" runat="server" />
            <div style="width: 60%; float: left; border: 1px solid #D8D8D8; background-color: #FFFFFF;">
                <asp:FormView ID="fvSanPhamDauGia" runat="server" Width="100%" OnPageIndexChanging="fvSanPhamDauGia_PageIndexChanging" OnItemCreated="fvSanPhamDauGia_ItemCreated">
                    <ItemTemplate>
                        <div id="sbox">
                            <div style="float: left; width: 30%; padding: 10px;">
                                <asp:HyperLink ID="HyperLink1" runat="server">
                                    <asp:Image ID="Image1" Width="200px" Height="200px" ImageUrl='<%# "~/images/"+Eval("HinhAnh") %>' runat="server" ImageAlign="AbsMiddle" Style="border: solid 1px #ccc;" />
                                </asp:HyperLink>
                            </div>
                            <div style="float: right; width: 60%; padding: 10px;">
                                <table border="0" class="tabledaugia" cellpadding="-2">
                                    <tr>
                                        <td colspan="2">
                                            <span style="font-weight: bold; color: #0072BC; font-size: 15px;"><%# Eval("TenSanPham") %></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Giá khởi điểm
                                        <br />
                                            <span style="font-weight: bold; color: black;"><%# Eval("GiaSan","{0:###,###}") %> VNÐ </span></td>
                                        <td>Giá thị trường
                                        <br />
                                            <span style="font-weight: bold; color: black;"><%# Eval("GiaThiTruong","{0:###,###}") %> VNÐ</span> </td>
                                    </tr>
                                    <tr>
                                        <td>Ngày lên sàn
                                        <br />
                                            <span style="font-weight: bold; color: black;"><%# String.Format("{0:hh:mm tt dd/MM/yyyy}", Eval("NgayLenSan")) %></span></td>
                                        <td>Ngày kết thúc
                                        <br />
                                            <span style="font-weight: bold; color: black;"><%# String.Format("{0:hh:mm tt dd/MM/yyyy}",DateTime.Parse(Eval("NgayLenSan").ToString()).Add(new System.TimeSpan(int.Parse(Eval("ThoiGianDauGia").ToString()),0,0,0))) %></span></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">Thời gian còn lại:
                                        <br />
                                            <div><%# Eval("Countdown") %></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:Button ID="btnStartAuction" Font-Names="Arial" CssClass="dgn_button" Text="Tham Gia Đấu Giá" runat="server" OnClick="btnStartAuction_Click" />
                                            <!--<input id="dgn_button" type="button" value="Tham gia đấu giá" onclick="window.location.href='Auction.aspx?Id=<%# Request.QueryString["Id"]%>    '" />-->
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:FormView>
                <div>
                    <div style="float: left; width: 40%; padding-left: 5px;">
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:Panel runat="server" ID="panelRating" Visible="false">
                                    <aj:Rating ID="rating" runat="server" BehaviorID="RatingBehavior1"
                                        CurrentRating="0"
                                        ReadOnly="true"
                                        MaxRating="5"
                                        StarCssClass="ratingStar"
                                        WaitingStarCssClass="savedRatingStar"
                                        FilledStarCssClass="filledRatingStar"
                                        EmptyStarCssClass="emptyRatingStar"
                                        OnChanged="rating_Changed"
                                        Style="float: left;" />
                                    <br />
                                </asp:Panel>
                                <div>
                                    <asp:Image runat="server" ImageUrl="~/images/like.png" ID="imageLike" Style="vertical-align: bottom;" />
                                    <asp:Button runat="server" ID="btnLike" Text="Like" OnClick="btnLike_Click" />
                                    &nbsp;&nbsp;<asp:Label runat="server" ID="txtSoNguoiLike" Text="+10" Font-Bold="true" Font-Size="14" ForeColor="#FBA310" />
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <br />
                        <div id="guide_icon">
                            <strong style="font-size: 18px; color: #FBA310">Hướng dẫn</strong>
                            <p>
                                <span id="caonhat"></span>Giá bạn đưa ra phải cao hơn giá sàn
                            </p>
                            <p>
                                <span id="rank_die"></span>Giá bạn đưa ra phải là cao nhất
                            </p>
                            <p>
                                <span id="rank_running"></span>Giá bạn đưa ra phải là duy nhất
                            </p>
                            <p>
                                <span id="boi50"></span>Giá bạn đưa ra phải là bội của 50.000
                            </p>
                        </div>
                    </div>
                    <div style="float: right; width: 55%;">
                        <asp:Panel runat="server" ID="panelDauGia">
                            <table style="width: 100%;">
                                <tr>
                                    <td style="width: 30%; text-align: right;">Giá:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtGiaDau" runat="server" CssClass="inputDauGia" Font-Size="14" Font-Bold="true" Style="text-align: right;" />
                                        (VNĐ)
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: right;">Mã bảo vệ:
                                    </td>
                                    <td>
                                        <asp:Image ID="imgcaptcha" AlternateText="Captcha" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtCaptcha" runat="server" CssClass="inputDauGia" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;
                                    </td>
                                    <td>
                                        <asp:Button runat="server" ID="btnDauGia" Text="&nbsp;&nbsp;&nbsp;Đấu giá&nbsp;&nbsp;&nbsp;" CssClass="button" OnClick="btnDauGia_Click" />
                                    </td>
                                </tr>

                            </table>
                        </asp:Panel>
                    </div>
                </div>
            </div>
            <div style="width: 38%; float: right; padding-right: 5px;">
                <asp:UpdatePanel ID="updateLstUserAuction" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <div style="min-height: 321px; overflow: auto; display: block; height: 370px;">
                            <asp:GridView runat="server"
                                ID="gvDanhSachDauGia"
                                ShowHeader="true"
                                AutoGenerateColumns="false"
                                Width="100%"
                                HeaderStyle-BackColor="#eeeeee"
                                Style="border: 1px solid #D8D8D8; background-color: #ffffff;"
                                OnRowDataBound="gvDanhSachDauGia_RowDataBound"
                                OnDataBound="gvDanhSachDauGia_DataBound">
                                <Columns>
                                    <asp:TemplateField HeaderText="STT" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <%# Container.DataItemIndex + 1 %>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="NguoiDungId" HeaderText="Người đấu giá" />
                                    <asp:BoundField DataField="GiaHienTai" DataFormatString="{0:###,###} " HeaderText="Giá đấu" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" />
                                </Columns>
                                <EmptyDataTemplate>
                                    <table style="width: 100%; border: 0px solid #D8D8D8;" border="0">
                                        <tr>
                                            <th style="text-align: center; width: 50px;">STT
                                            </th>
                                            <th style="text-align: center;">Người đấu giá
                                            </th>
                                            <th style="text-align: right;">Giá đấu
                                            </th>
                                        </tr>
                                        <tr>
                                            <td colspan="3" style="border-top: 1px solid #D8D8D8;">Sản phẩm này chưa có ai tham gia đấu giá.
                                            </td>
                                        </tr>
                                    </table>

                                </EmptyDataTemplate>
                            </asp:GridView>
                            <asp:Timer ID="timer" runat="server" OnTick="timer_Tick" Interval="1000" />
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>




        <span id="ctr_today" style="margin-top: 10px; margin-left: 5px; margin-bottom: 10px;">Mô tả sản phẩm</span>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Chi tiết sản phẩm</a></li>
                <li><a href="#tabs-2">Bình luận</a></li>
            </ul>
            <div id="tabs-1">
                <asp:FormView ID="fvMoTa" runat="server" Width="100%">
                    <ItemTemplate>
                        <%# Eval("MoTa") %>
                    </ItemTemplate>
                </asp:FormView>
            </div>
            <div id="tabs-2">
                <div>
                    <asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Rows="3" Font-Names="Arial" Width="700px" /><br />
                            <asp:Button ID="btnComment" runat="server" OnClick="btnComment_Click" Text="Bình luận" CssClass="button primary" Font-Names="Arial" />
                            <br />
                            <br />
                            <asp:DataList ID="dataListComment" runat="server" OnItemDataBound="dataListComment_ItemDataBound">
                                <ItemTemplate>
                                    <div style="float: left; width: 50px;">
                                        <img src="images/user_blue.png" />
                                    </div>
                                    <div style="float: left; width: 700px;">
                                        <div style="font-weight: bold;">
                                            <asp:Label ID="labelTenNguoiDung" runat="server" Text='<%# Eval("NguoiDungId") %>'></asp:Label>
                                        </div>
                                        <div style="padding-top: 8px;">
                                            <%# Eval("NoiDung") %>
                                        </div>
                                        <div style="border-bottom: solid 1px #ccc; padding-top: 5px; font-size: 12px; padding-bottom: 5px;">
                                            <asp:Label ID="labelTime" runat="server" Text='<%# Eval("NgayTao", "{0:hh:mm tt dd/MM/yyyy}") %>'></asp:Label>
                                        </div>
                                        <br />
                                        <br />
                                    </div>

                                </ItemTemplate>
                            </asp:DataList>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>
        <script>
            cdtd();
        </script>
    </form>
    <br />
</asp:Content>
